aiSEGcell: User-friendly deep learning-based segmentation of nuclei in transmitted light images

Segmentation is required to quantify cellular structures in microscopic images. This typically requires their fluorescent labeling. Convolutional neural networks (CNNs) can detect these structures also in only transmitted light images. This eliminates the need for transgenic or dye fluorescent labeling, frees up imaging channels, reduces phototoxicity and speeds up imaging. However, this approach currently requires optimized experimental conditions and computational specialists. Here, we introduce “aiSEGcell” a user-friendly CNN-based software to segment nuclei and cells in bright field images. We extensively evaluated it for nucleus segmentation in different primary cell types in 2D cultures from different imaging modalities in hand-curated published and novel imaging data sets. We provide this curated ground-truth data with 1.1 million nuclei in 20,000 images. aiSEGcell accurately segments nuclei from even challenging bright field images, very similar to manual segmentation. It retains biologically relevant information, e.g. for demanding quantification of noisy biosensors reporting signaling pathway activity dynamics. aiSEGcell is readily adaptable to new use cases with only 32 images required for retraining. aiSEGcell is accessible through both a command line, and a napari graphical user interface. It is agnostic to computational environments and does not require user expert coding experience.


Introduction
Image segmentation-the partitioning of an image into meaningful segments-is fundamental to image analysis.It is usually the first step in image analysis pipelines to identify tissues, cells or subcellular structures to then allow their state quantification or tracking and dynamics quantification [1].Accurate segmentation is usually crucial for robust automated downstream analyses [2].While manual image segmentation is considered the gold standard, segmentation for high throughput microscopy requires computer assistance.Conventional computer-assisted image segmentation is semi-automated and necessitates good signal-to-noise, using a dedicated fluorescence channel for segmenting cells, nuclei, or other targets [3][4][5].However, dedicating a fluorescence channel to facilitate image segmentation loses a channel that would otherwise be available to image other relevant targets and increases imaging phototoxicity and required acquisition times [6].Furthermore, adding a transgenic fluorescence marker increases the size of genetic constructs, complicates experimentation and reduces virus packaging and transduction efficiency [7].Similarly, the time and cost associated with establishing and maintaining a transgenic animal line increases considerably with each additional transgene.Eliminating the need for fluorescent markers for segmenting cellular structures would thus greatly improve imaging experiments.This is made possible by segmenting cells and their compartments in transmitted light images.Albeit visible in transmitted light images, features indicative of even a large organelle like the nucleus are complex, vary between cell types, and over time, for example due to cell differentiation, cell movement or changes in the focal plane.Neural networks excel at discovering complex informative features and are not limited to specific imaging conditions or cell types if trained on a large representative data set [8][9][10][11].Previous research has shown that neural networks can automatically detect nuclei and other sub-cellular structures in high magnification bright field (BF) images [12,13].Moreover, U-Net has been suggested as a well-suited model architecture for this purpose, potentially even for low magnification imaging [14][15][16].However, it is uncertain whether nuclei can be accurately segmented under challenging typical imaging conditions optimized for speed and cells' health and not for perfect images, such as low magnification BF microscopy.Furthermore, actively maintained, user-friendly software for segmenting nuclei in BF is not available.Consequently, widespread experimental adoption remains elusive.
Here, we present "aiSEGcell" a user-friendly software to segment nuclei in BF images accessible even to users with no prior coding experience.We demonstrate its utility even in challenging prevalent conditions, including low magnification live time lapse imaging of primary cells.This includes small hematopoietic stem and progenitor cells lacking prominent and large cell compartments like cytoplasm, also in microfluidic and other culture devices.More specifically, we quantify both technical performance metrics and the preservation of biologically meaningful information such as live single cell signaling dynamics.We show that our trained instance of aiSEGcell is transferable to unseen experimental conditions and adaptable to other use cases, like novel cell types, only requiring 32 images for retraining.
Finally, we demonstrate aiSEGcell's benefits by quantifying an additional fluorescence channel in an experimental setting where the number of biomarkers is limited by their spectral properties.aiSEGcell is accessible through a command line interface (CLI) or a graphical user interface (GUI), a napari plugin, tested by users with varying coding experience in different computational environments [17].In addition, we provide the five used data sets, containing more than 20,000 images, and 1,100,000 nuclei, as open access data through a FAIR repository [18].

Segmenting nuclei in common bright field images
Conventional cell segmentation approaches use fluorescence to mark cells and cell compartments for segmentation (Fig 1a).In contrast, aiSEGcell omits fluorescence markers for segmentation and directly segments BF images (Fig 1b).We selected U-Net as the model architecture [12,14] for aiSEGcell and trained it on 9,849 BF image and segmentation mask pairs (>600,000 nuclei) of live primary murine hematopoietic cells, like macrophages, stem and progenitor cells, at 20x magnification (D1) [16].To highlight the need for user-friendly software that segments nuclei in BF, we compared aiSEGcell to widely used nucleus segmentation software Cellpose and StarDist [19,20].Available pretrained models for nucleus and BF segmentations were not suitable alternatives to the specialized BF nucleus segmentation of aiSEGcell (S1 Fig and S1 and S2 Tables).We evaluated aiSEGcell on a second data set (D2) comprised of 6,243 image-mask pairs (>300,000 nuclei) derived from five independent imaging experiments with experimental settings similar to D1. Cell morphologies included round https://doi.org/10.1371/journal.pcbi.1012361.g001cells and more complex shaped cells with protruding pseudopodia.In addition, cell sizes varied by an order of magnitude (Table 1).aiSEGcell segmented nuclei in BF images across morphologically distinct cells and different scales (Figs 1c and S2a).We quantified segmentation quality using an adapted version of the F1-score that counted inaccurately predicted objects (e.g.intersection over union = 0.4) as one error instead of as both, false positive (FP), and as false negative (FN; see Materials and methods).Therefore, the image-wise average adapted F1-score with an intersection over union (IOU) threshold of 0.6, denoted as F1 0:6 avg , more appropriately represented the observed segmentation quality [21].aiSEGcell nuclear segmentations in BF were quantitatively similar to nuclear marker derived segmentations (ground truth; F1 0:6 avg = 0.66).Around 70% versus 5% of images had F1 0.6 �0.6 versus F1 0.6 �0.4,illustrating that aiSEGcell segmentations are consistently accurate across challenging typical BF images (Fig 1d and S3 Table).Furthermore, we quantified the frequency of oversegmentations (an object like a nucleus in the ground truth segmentation is split into multiple objects in the aiSEGcell segmentation) and undersegmentations (multiple objects in the ground truth segmentation are merged into a single object in the aiSEGcell segmentation).Only 0.2 (s.d.= 0.5) of 50 ground truth nuclei were oversegmented in aiSEGcell segmentations and 0.2 (s.d.= 0.6) of 50 nuclei detected in aiSEGcell were merged ground truth nuclei per image on average in D2 (S4 Table ).Images in D2 were intended for cell tracking and consequently not of high cell density.To evaluate if undersegmentations were more frequent in images dense with cells, we acquired an additional data set (D7) with densely seeded cells.aiSEGcell accurately (F1 0:6 avg = 0.80) segmented nuclei in BF and undersegmentations rarely occurred.Only 0.2

aiSEGcell is sufficient to quantify noisy dynamics data
Mask-level performance evaluation of segmentation models may not be relevant to illustrate suitability for downstream applications.Consequently, evaluating segmentation models with respect to biologically meaningful read-outs is necessary.The translocation of fluorescently labeled signaling molecules from the cytoplasm to the nucleus and vice versa, in small motile live primary cells imaged with low signal-to-noise is demanding, sensitive to variations in the nuclear mask and has been shown to affect cell behavior and fate [22][23][24].We used a homozygous reporter mouse-line that had all p65 proteins, the transcriptionally active part of the nuclear factor κB (NfκB) dimer, tagged with green fluorescent protein (GFP) to quantify its translocation to the nucleus upon NfκB signaling activation (Fig 2a

aiSEGcell is easily adaptable to new experimental conditions
Once trained, neural networks have the potential to be applied indefinitely to data of the same distribution, in some cases even to new data distributions.This training process is notoriously challenging and requires hardware resources that are prohibitive for many users.Consequently, it is important to investigate the robustness of a neural network to unseen data.We tested aiSEGcell trained on D1 on a published unseen data set (D5) comprised of human multipotent progenitor populations (hMPP) cultured in a microfluidic chip acquired by an unseen experimenter on an unseen microscopy setup (Figs 3a and S2b and Tables 1 and S6).We repeated the published data processing to obtain single cell extracellular signal-regulated kinase (ERK) pathway signaling dynamics, now using aiSEGcell segmentation masks.Finally, we automatically assigned ERK signaling dynamics to one of four response types: NON, TRA, intermediate (INT), SUS [22,26].ERK signaling dynamics obtained from aiSEGcell segmentations were similar to those based on ground truth segmentations (average Euclidean distance = 0.50, n = 126; Fig 3b).Overall, the signaling dynamics classifications corresponded very well between manually curated or aiSEGcell segmented nuclei, illustrating aiSEGcell's usability: 81% of aiSEGcell response type assignments matched the ground truth signaling dynamics (NON: 94%, TRA: 36%, INT: 69%, SUS: 88%; Fig 3c).TRA signaling dynamics had a lower classification overlap.However, closer inspection of their dynamics data showed that 'misclassified' aiSEGcell signaling dynamics curves were actually very similar to those from manually curated nucleus segmentations.They had a good average Euclidean distance of 0.51 demonstrating the similarity of aiSEGcell and ground truth signaling dynamics.Thus, the differences in classifying a TRA response do not stem from clear differences in manually curated versus aiSEGcell segmentation, but from the high sensitivity of the used classification parameters to minor changes in curve properties (due to the used cut-offs of signal returning to baseline) [26].As shown in S5 Fig, these very small segmentation deviations would likely not be considered biologically relevant by an expert.Small focus changes due to technical problems or cell differentiation are usually detrimental to segmentations.Therefore, we tested aiSEGcell's robustness against focus drifts.We imaged murine granulocyte/monocyte progenitors (mGMP) with focal planes in the range of ±10 μm (step-size 0.2 μm) equally distributed around the optimal focal plane selected by the experimenter (n = 24 images, N = 1 biological replicate).Segmentations of D1 trained aiSEGcell of all 101 focal planes were compared to the ground truth segmentation in the optimal focal plane.The F1 0:6 avg was 0.88 versus >0.80 for the optimal focal plane versus a range of 4.4 μm (-1.8 μm to +2.6 μm).This range approximately corresponds to the radius of most primary hematopoietic cells, suggesting that aiSEGcell can accurately segment nuclei in BF as long as the focal plane aligns with parts of the nucleus and demonstrating its robustness to focus changes (S2 and S6 Figs and S7 and S8 Tables).
The diversity of BF imaging data will inevitably lead to use cases to which aiSEGcell trained on D1 does not generalize well.For example, megakaryocytes have large, lobated nuclei that are morphologically very different from the nuclei observed in D1 or D2.Hence, we tested the feasibility of adapting aiSEGcell pretrained on D1 to a data set containing murine megakaryocytes (mMEG) co-cultured with murine hematopoietic stem cells (mHSC; D3; Figs 3d and S7a and S9 and S10 Tables).To prevent overfitting on a single experiment, we used one separate biological replicate for training, validation, and test set, respectively (Table 1).We then retrained aiSEGcell with a small set of 34 images, realistic for a typical experimental laboratory use case, to improve mMEG nucleus segmentations.Whereas the pretrained model could detect nuclei of mHSCs, it failed to segment the much larger nuclei of mMEGs (nucleus mask > 750 μm 2 ; Figs 3e and S2c).Retraining aiSEGcell significantly improved segmentations of mMEG nuclei from an average image-wise IOU of 0.02 to 0.77 (pre-/ retrained s.d.= 0.05 / 0.08; Fig 3f and S11 Table ).The average image-wise IOU of small cells (i.e.mHSCs; nucleus mask � 750 μm 2 ) improved from 0.38 to 0.64 due to the training data containing both large and small cells (S8 Fig) .Following the same strategy, we compiled a data set of adherent nonround murine embryonic stem cells (mESC; D4; Table 1).While the pretrained model failed to segment mESC nuclei, retraining aiSEGcell with 32 images enabled it to segment mESC nuclei in BF images, significantly improving the F1 0:6 avg from 0.01 to 0.93 (pre-/ retrained s.d.= 0.01 / 0.02; Figs 3d, 3g, 3h, S2d, and S7b and S12-14 Tables).Of note, retraining aiSEGcell on D3 or D4 decreased its segmentation accuracy on D2 (D1 trained / D3 retrained / D4 retrained F1 0:6 avg = 0.66 / 0.27 / 0.12; S3 Table ).Training aiSEGcell with only 32 images on a mid-class graphics processing unit (i.e.NVIDIA TITAN RTX) for 1,500 epochs (i.e.iterations over the 32 images) took approximately four hours.
Segmentations with aiSEGcell are based on BF images rich in information about cells, cell interactions, and sub-cellular structures.Understanding which information in BF images is crucial for accurate nucleus segmentations can help efficiently assembling data sets for retraining.Therefore, we selected 999 cells from D2 that aiSEGcell segmented accurately (i.e.high IOU) and 951 cells from D2 that aiSEGcell segmented poorly (i.e.low IOU).Next, we extracted 21 conventional shape and intensity features that describe the nucleus, the whole cell, and the cell neighborhood given the corresponding segmentation masks (S9 and S10 Figs and S15 Table ).Taken individually, extracted features were not indicative of whether a cell was segmented accurately or not (S11 Fig) .However, training a random forest to classify if a cell is segmented accurately or not (test accuracy = 0.85) revealed that features associated with the nucleus of a cell were more important than features of the whole cell or the cell neighborhood (S12 Fig) [27].We visually confirmed the importance of nuclear features in BF images by directly interpreting aiSEGcell segmentations with Grad-CAM [28]

Using aiSEGcell software
aiSEGcell is an open source software accessible through a CLI (https://github.com/CSDGroup/aisegcell) or a GUI (napari plugin, https://github.com/CSDGroup/napariaisegcell)[17].The CLI version can be used to train, test, and predict with aiSEGcell.Training a neural network is challenging and may require tweaking many different parameters for good performance.Therefore, we provide extensive documentation and notebooks to help users getting started with our tool.We asked a group of 5 testers composed of computationally in  The GUI can only be used for inference and has two modes.The layer mode is intended to explore if representative images of the user's data set can be segmented accurately with available segmentation models or if a new model should be trained with the CLI version.Users can select either one of the two models shipped with the CLI version for segmentation or select a custom model trained in the CLI.If graphical processing units are available, the GUI version will automatically detect and use them enabling faster inference.Moreover, the GUI contains optional postprocessing steps to e.g.dilate or erode masks at run-time.Once the appropriate model and postprocessing settings have been determined in the layer mode, the batch mode enables high-throughput segmentation of images stored even in different folders.While model selection and postprocessing are identical to the layer mode, images are submitted for segmentation via file lists.File lists are agnostic to laboratory specific image storage structure, thus reducing the overhead of copying, renaming and moving imaging data for segmentation.Users can load existing file lists or create new file lists within the GUI.As with the CLI version, we asked a group of six testers with varying computational experience to install and use the GUI version given its online documentation.All testers successfully installed the plugin within 15 minutes and successfully used both modes of the GUI on macOS, Windows, or Ubuntu.

Discussion
We describe aiSEGcell, a user-friendly software to segment nuclei from only BF images without the need for fluorescent nuclear labeling.Previous research has demonstrated that neural networks can detect nuclei and other cell organelles in transmitted light images under optimized conditions [12,13,15].We now show that nuclear segmentations in BF are also feasible in challenging common experimental conditions like low magnification, and time lapse imaging of e.g.small non-adherent primary murine and human hematopoietic cells imaged in microfluidic and other culture devices.Notably, we prove that these segmentations are so similar to manual segmentation that they retain biologically meaningful information even when using the segmentation as the basis for quantification of difficult and noisy reporters like biosensors for cell signaling dynamics.
By freeing up a fluorescent channel, aiSEGcell facilitates the exploration of additional fluorescent markers or the reduction of phototoxicity and required imaging times.We demonstrate that aiSEGcell can thus add biological information to an experiment previously constrained due to e.g.poor fluorophore markers in an existing transgenic mouse model.More specifically, we explore the effect of NfκB signaling dynamics on the differentiation of mGMP GM and correct for the cell cycle as a potential covariate.Other signaling pathways like ERK in mESCs change their response dynamics depending on CC phases [23].In contrast, here we find that cell cycle progression does not affect NfκB signaling responses to TNFα stimulation in mGMP GM cells.At a broader level, we show how aiSEGcell enables new experimental workflows and its utility in jointly investigating multiple signaling pathways, differentiation markers, and control variables.
The ability to generalize to many use cases is a sought-after feature in trained neural networks and it is crucial for democratizing access to state-of-the-art machine learning.Conventionally, large models are trained on vast amounts of data to obtain generalizability [11,32,33].However, microscopy data are highly diverse and siloed impeding the availability of broadly representative data sets.To address this challenge, crowdsourcing platforms have been used to annotate large data sets [34].Alternatively, periodic retraining with user provided data has been suggested [20].Here, we demonstrate that aiSEGcell pretrained on a large data set requires only approximately 30 images to drastically improve segmentation for new use cases.
Consequently, aiSEGcell retraining is feasible for users with little computational resources and improves access to state-of-the-art image segmentation.
Sharing data in FAIR repositories is crucial to advance research on computer vision and disseminate computer vision applications [18].Hence, we share our data sets D1-5 containing manually curated nuclear marker ground truth segmentations of more than 20,000 images, or 1,100,000 nuclei, covering 11 unique cell types (one cell line, 10 primary cell types; Figs 1-3 and Table 1).With 20,000 images and 1.1 million nuclei, these data sets are among the largest publicly available data sets for fluorescence or label free nucleus segmentation to date [34][35][36][37].Thus, we believe that our data sets can be a valuable resource to the community in advancing image segmentation software.
Programming experience is a major limiting factor preventing the broader adoption of machine learning in biology.New machine learning methods are often available as public code repositories that lack the necessary testing to ensure compatibility with different computational environments and are not actively maintained [12,13].This is further accentuated in notoriously difficult to train neural networks implemented in complex frameworks that are subject to frequent changes [38,39].Therefore, it is crucial to release scientific software that is well documented and accessible to programming novices [3,5,20,40].For the first time, we introduce a software for segmenting nuclei in BF images, proven to work across various computational environments and user coding proficiency levels.We release aiSEGcell with already trained models to segment nuclei and whole cells in BF.The software is available as CLI and GUI versions for easy accessibility.Importantly, aiSEGcell utilizes a generic image segmentation approach not limited to BF microscopy [16].Hence, users can retrain an existing aiSEGcell model or train a new aiSEGcell model to segment other objects in different 2D image modalities, for example fluorescently labeled blood vessels or cell organelles in electron microscopy, etc., further enhancing its utility in a wide range of applications.

Ethical statement
The research presented here complies with all relevant ethical regulations.Animal experiments were approved according to Institutional guidelines of Eidgeno ¨ssische Technische Hochschule Zu ¨rich and Swiss Federal Law by the veterinary office of Canton Basel-Stadt, Switzerland (approval no.2655).Relevant ethical regulations were followed, according to the guidelines of the local Basel ethics committees (vote 13/2007V, S-112/2010, EKNZ2015/335) or the ethics boards of the canton Zurich (KEK-StV-Nr.40/14).

Mice
Previously published transgenic mice were used for D1, D2, D6 and C57BL/6j mice were used for D3 [25,29].Experiments were conducted with 10-16-week-old (D1, D2, D6) or 8-12-weekold mice (D3) and only after mice were acclimatized for at least 1 week.Mice were housed in improved hygienic conditions in individually ventilated, environmentally enriched cages with 2-5 mice per cage and ad libitum access to standard diet and drinking water.Mice were housed in a humidity (55 ± 10%) and temperature (21 ± 2 ˚C) controlled room with an inverse 12 h day-night cycle.Animal facility caretakers monitored the general well-being of the mice by daily visual inspections.Mice displaying symptoms of pain and/or distress were euthanized.Mice were randomly selected for experimental conditions and in some cases pooled to minimize biological variability.

Virus production and transductions (D6)
Lentiviruses were produced and transduced as previously described [45].In brief, PCNA was fused to fluorescent protein mRUBY2 and cloned into vesicular stomatitis virus glycoprotein pseudotyped lentivirus (third generation) constructs using the In-Fusion Cloning system (Takara Bio) [46][47][48].The virus was produced in human embryonic kidney 293T cells and titrated using NIH-3T3 fibroblasts.Lentivirus was added at a multiplicity of infection of 50-100 to fluorescence-activated cell sorting (FACS) purified mPreGMs in a round bottom 96-well plate for 36 h (37˚C, 5% O2, and 5% CO2) before purifying transduced cells by FACS.

Time lapse imaging (D4)
First, 3,000 mESCs were seeded per channel of an E-Cadherin coated μ-slide (ibidi) in NDiff227 medium containing doxycycline (Dox; 1 ng/mL; Sigma-Aldrich) and overlaid with silicone oil.After approximately 20 h, cells were washed 5x to remove Dox and the medium was replaced with NDiff227 containing different combinations of the small molecules Dox, trimethoprim (Sigma-Aldrich), and 4-hydroxytamoxifen (Sigma-Aldrich).Imaging was performed on Nikon Eclipse Ti-E microscopes equipped with 10x/0.45CFI Plan Apochromat λ objective, Hamamatsu Orca Flash 4.0 cameras, and Spectra X fluorescent light source (Lumencor).Images were acquired using custom software [53].All time lapse experiments were conducted at 37˚C, 5% O2, and 5% CO2.Only a single time point of the time lapse experiment was used for all experiments involving D4 (S16 Table ).

Isolation, imaging, and image quantification of hMPPs (D5)
Experiment 26 on hMPPs (S16 Table ) has previously been published [22].Signaling dynamics derived from aiSEGcell segmentations were processed and quantified with the respective analysis pipeline.

Confocal time lapse imaging (D6)
Experiments were acquired using Nikon NIS acquisition software on a Nikon W1 SoRa Spinning Disk confocal microscope with a Hamamatsu ORCA-Fusion camera, 20x/0.75CFI Plan Apochromat λ objective, and Spectra X (Lumencor) light source for BF.Media conditions for mGMP GM were as described above.Images were acquired every 9 min for 36 h.After 1 h, the movie was briefly stopped to stimulate cells with control media or TNFα-supplemented media (40 ng/mL final concentration).All time lapse experiments were conducted at 37˚C, 5% O2, and 5% CO2 (S16 Table ).

Image quantification and analysis (D1/D2/D3/D4/D6)
Images were processed and quantified as previously described [5,25,48,[54][55][56][57][58][59].In brief, 12-bit or 16-bit images were saved as TIFF-files and linearly transformed to 8-bit PNG-files using channel-specific black-and white-points.Fluorescence channels were background corrected for D3 and D4.Images were segmented and individual cells of D2 and D6 were tracked for subsequent fluorescence channel quantification.Missing values due to missing masks were mean imputed.For D2 NfκB normalization, mean nuclear NfκB intensities were computationally resampled in intervals of 7 min using linear interpolation to account for the different experimental imaging frequencies.Mean NfκB intensity was divided by the cell-wise average of mean NfκB intensity prior to stimulation and rescaled to a range of 0 and 1 using experiment-wise min-max scaling.For D6 NfκB normalization, mean nuclear NfκB intensity was divided by mean whole cell NfκB intensity.Normalized NfκB signal was divided by the cellwise average of normalized NfκB signal prior to stimulation to obtain baseline normalized NfκB signal used for subsequent analysis.Cell cycle phases were manually assigned during cell tracking.Ly6C and CD115 status was assigned by thresholding on the whole cell mean intensity divided by the cell-wise average of whole cell mean intensity prior to stimulation.For Ly6C, cell-wise mean and standard deviation prior to stimulation were computed to set threshold = mean+5 * s.d..For CD115, cell-wise mean prior to stimulation were computed to set threshold = 3 * mean.Assignments of Ly6C and CD115 status were manually confirmed.NfκB signaling dynamics were normalized and classified in R (4.0.2).

Image segmentation
Ground truth nuclear masks were obtained by manually curating fastER segmentations [5].In brief, fastER uses human-in-the-loop region annotations to train a support vector machine that segments candidate regions based on shape and texture features and uses a divide and conquer approach to derive an optimal set of non-overlapping candidate regions.fastER was trained experiment-wise on the respective nuclear marker channel and resulting masks were eroded (settings: dilation -2).fastER accurately segmented most nuclei, but light path differences between fluorescence and BF (e.g.shadow obstructing cell in BF) or, for example, focus shifts of live non-adherent cells led to missing or inaccurate object segmentations.Consequently, inaccuracies in segmentations were manually curated with a custom napari plugin if necessary [17].aiSEGcell segmentations were obtained by predicting and thresholding (0.5) on a single foreground channel from BF images with the respective trained model and subsequently removing small objects (skimage.morphology.remove_small_objects)and small holes (skimage.morphology.remove_small_holes)with experiment-specific settings.Semantic segmentations were converted to instance segmentations using connected components (skimage.measure.label)[60].Whole cell segmentation masks for D6 experiments were obtained using the aiSEGcell model to segment whole cells in BF accessible through CLI and GUI.For D5 and D6, aiSEGcell segmentations were manually curated in BF if necessary [55].

Focus experiment
Murine GMPs were isolated from a C57BL/6j mouse as described above.Cells were stained with SPY650-DNA (1:1,000; Spirochrome) for 60 min on ice.The experiment was acquired using Nikon NIS acquisition software on a Nikon W1 SoRa Spinning Disk confocal microscope with a Hamamatsu ORCA-Fusion camera with a 20x/0.75CFI Plan Apochromat λ objective, and Spectra X (Lumencor) light source for BF.The experimenter manually selected the optimal focal plane and focal planes in the range of ±10 μm (step-size 0.2 μm) equally distributed around the optimal focal plane were acquired for 24 field-of-views.Media conditions for mGMPs were as described above.Images were processed as for D1.Ground truth segmentations were obtained using fastER on the nuclear fluorescence signal of the optimal focal plane, (D1-trained) aiSEGcell segmentations were obtained for all focal planes [5].

NfκB signaling dynamics classification
NfκB signaling dynamics were classified as NON, OSC, SUS, TRA, or unclear/outlier by the experimenter.The experimenter was blind to the experimental conditions of the randomly displayed signaling dynamics and responder-, OSC-, and SUS-TRA-scores were displayed [25].

F1 computation
We quantified segmentation performance with two types of F1-scores.The conventional F1-score was implemented as previously described [61].In brief, object-wise IOUs were computed for each object in a ground truth segmentation mask and the predicted segmentation mask.Ground truth objects with an IOU>τ 1 were considered a true positive (TP).Ground truth objects with no matching predicted object (IOU�τ 1 ) and predicted objects with no matching ground truth object were considered FN and FP, respectively.We then computed F1 ¼ 2 * TP 2 * TPþFPþFNþε , with ε a small numerical term to prevent division by 0, for varying thresholds τ 1 (0.5-0.9 in 0.05 increments), Conventional F1-scores were provided in S2, S3, S5, S6, S8, S10, S11, S13, and S14 Tables.
We observed that most errors were nuclei segmented with only small inaccuracies, which were nevertheless counted as FP and FN.This led the conventional F1-score to underestimate the segmentation quality (S16 Fig) .Therefore, we introduced a second threshold (τ 2 = 0.1) to prevent counting inaccurately predicted objects (e.g.IOU = 0.4) as both, FP, and as FN.FPs were objects in the prediction with IOU�τ 2 and FNs were objects in the ground truth with IOU�τ 2 .We introduced the category of inaccurate masks (IA), ground truth objects with exactly one τ 2 <IOU�τ 1 and computed the adapted image-wise F1 ¼ 2 * TP 2 * TPþFPþFNþIAþε .Given the small size of primary cell nuclei at 20x magnification (many nuclei <100 pixels) and the sensitivity of the F1 computation to object size, we observed τ 1 = 0.6 to be an appropriate threshold and denoted the image-wise average adapted F1-score with τ 1 = 0.6 as F1 0:6 avg throughout this manuscript [21,61,62].Analogous to the conventional F1-score, we provided the adapted F1-score for varying τ 1 thresholds (S1, S3, S5-S7, S9, S11, S12, and S14 Tables).Ground truth objects with τ 2 <IOU�τ 1 for more than one predicted object were considered a split.Predicted objects with τ 2 <IOU� τ 1 for more than one ground truth object were considered a merge.

aiSEGcell performance evaluation
For D2 and D4 we evaluated the performance of aiSEGcell using the F1-score.Due to low magnification imaging of small (primary) cells, segmentation masks were in part <100 pixels.Consequently, object-level performance metrics (i.e.F1-score) were more adequate for performance evaluation and less sensitive to noise level deviations of a few pixels.Images in D3 contained both mHSC and mMEG with mMEG segmentation quality being more relevant to the task.While F1-scores helped assess segmentation errors for the co-culture setting they did not qualify to evaluate the segmentation quality of a subset of cells in an image.Hence, we evaluated the performance of aiSEGcell on mMEG using object-wise IOU.Megakaryocyte nuclei were >2,000 pixels in size and noise level deviations of a few pixels did not impede the explanatory power of object-wise pixel-level performance metrics (i.e.IOU).

aiSEGcell model selection
U-Net was selected as model architecture due to its wide and robust applicability in biological image segmentation [16,63].Leaky ReLU and batch normalization were used in convolutional blocks [64,65].Two convolutional blocks and a maximum pooling layer or bilinear upsampling layer formed the down-and upscaling blocks, respectively.Convolutional kernels (3x3) were padded, and the number of kernels doubled with each downscaling block (capped at 512), starting at 32.The number of kernels halved with each upscaling block.In total, 7 downscaling blocks were used to result in a receptive field of 128x128 pixels for the lowest layer kernels.Model instances were trained on randomly augmented (flipping, rotation) 1,024x1,024-pixel images or random crops of 1,024x1,024 pixels from larger images.For D3 and D4 retraining, random blurring/sharpness augmentations were additionally used to improve training on the very small and less diverse training data.Binary cross entropy was used as loss function.
For D1 training, model instances were trained for 400 epochs with a batch size of 14, the maximum batch size to fit on two NVIDIA TITAN RTX GPUs during training.The weight of the loss function was 1. Model instances were initialized with random weights and three replicates for each learning rate (5e-3, 1e-3, 5e-4, 1e-4) were trained [66].The best model was selected based on the highest average image-wise F1-score on the validation set.For D3 retraining, model instances were initialized with the weights of the best model instance trained on D1 and were trained for 1,500 epochs with a batch size of 4 to balance generalizability and the small training set size.The learning rate was fixed at 1e-5 and three replicates for each loss weight (1,2,3,4,5,6,7,8,9,10,20,50,100,150,200) were trained.The best model was selected based on the highest average image-wise IOU for big cells on the validation set.For D4 retraining, model instances were initialized with the weights of the best model instance trained on D1 and were trained for 1,500 epochs with a batch size of 4. A grid search to find the best model instance considered learning rate (5e-5, 1e-5, 5e-6, 1e-6) and loss weight (1, 2, 3) with three replicates for each hyperparameter combination.The best model was selected based on the highest average image-wise F1-score on the validation set.

Cellpose and StarDist pretrained model evaluation
We used Cellpose version 3.0.7 and selected "nuclei" as a generalist nucleus segmentation model and "yeast_BF_cp3" as a bright field round object segmentation model [20].A grid search to find the best post-processing hyperparameters considered diameter (17,30,40) and flow threshold (0.2, 0.4, 0.6).

Shape and intensity feature computation
We selected 3,053 images of D2 that did not cause an error during feature computation (i.e.cell contour identification) due to too close cell masks.In this subset of D2, for all experiments selected the 200 cells with the highest IOU and 200 cells with the lowest IOU.After manual curation 1,950 cells (999 high, 951 low) remained, for which nucleus and whole cell masks were available (aiSEGcell whole cell segmentation).The 21 shape and intensity features were computed as described (S15 Table) [60,67].

Random forest analysis
The best random forest classifier was selected by a grid search over training set size (50, 100, 200, 300, 400, 500, 600, 700, 800, 1,000), number of estimators (20,50,100,200,300,400,500,600), and maximum estimator depth (5,7,9,11,13) with 4-fold cross validation.Training and test sets were balanced, and cells were randomly selected from the 1,950 available cells.The best model had 600 estimators with a maximum estimator depth of 7 and was trained on 200 cells.Feature importances were based on the Gini importance.The scikit-learn implementation of random forest was used [68].

Fig 1 .
Fig 1. aiSEGcell accurately segments nuclei in bright field images.(a) Workflow to segment nuclei based on nuclear marker or (b) BF (cyan; scale bars 40 μm).(c) Nuclear segmentations in BF were qualitatively similar to fluorescent nuclear marker derived segmentations.Each field-of-view stems from a different independent experiment of data set D2 (scale bars 10 μm).(d) Nuclear segmentations in BF (b) were quantitatively similar to nuclear marker derived segmentations (a) in D2 (n = 6,243 images, N = 5 experiments).The F1-score ranges between 1 (best) and 0 (worst) and the image-wise average F1 with an intersection over union threshold of 0.6 is denoted as F1 0:6 avg .Given the challenges of imaging live primary non-adherent cells we consider F1 0.6 �0.6 good.The results in Figs 2, 3c and 4c support this estimate.Images were cropped from a larger field-of-view and contrast was individually adjusted here for visibility.

Fig 2 .Fig 3 .
Fig 2. aiSEGcell is sufficient to retain demanding biologically meaningful information.(a) NfκB signaling dynamics obtained from a representative single tracked primary murine granulocyte/monocyte progenitor cell.The magenta bar and dashed line illustrate a single addition of TNFα after 1 h.Contrast was individually adjusted here to improve visibility (scale bars 10 μm).(b) Signaling dynamics in D2 divide into four response types: non-responsive (NON), oscillatory (OSC), sustained (SUS), and transient (TRA).Signaling dynamics obtained from D1-trained aiSEGcell (cyan) were qualitatively similar to manually curated nuclear marker derived signaling dynamics (black) [25].Exemplary signaling dynamics from all independent experiments of D2 are displayed with ground truth response types.The length of signaling dynamics varies due to different experimental settings in D2 experiments.Euclidean distance (D) illustrates similarity between ground truth and aiSEGcell signaling dynamics.Larger D correspond to larger dissimilarity between signaling dynamics and D = 0 for identical signaling dynamics.(c) Single cell signaling dynamics response type assignments were similar between aiSEGcell-derived and fluorescent nuclear marker-derived signaling dynamics.Four aiSEGcell signaling dynamics were classified as outliers due to many missing segmentation masks and were omitted from the confusion matrix for clarity (n = 458 signaling dynamics, N = 5 experiments).https://doi.org/10.1371/journal.pcbi.1012361.g002 -and experienced users to install and use the CLI version based only on its online documentation.All testers successfully installed the CLI version within 15 minutes and were able to train, test, and infer with aiSEGcell on macOS, Windows, or Ubuntu.Finally, we provide users with two pretrained models.The model trained on D1 (S1 Fig), and a model trained to segment whole cells in BF.

Table 1 . Data sets overviews.
d. = 0.5) out of 50 nuclei detected by aiSEGcell were merged ground truth nuclei per image on average (S3 Fig and S4 and S5 Tables).